#ifndef _GIOP_H
#define _GIOP_H


#define GIOPMAXPAR NBANDS

/* optimization routines */
#define AMOEBA    0
#define LEVMARQ   1
#define SVDFIT    3

/* adg function types */
#define ADGTAB    0
#define ADGS      1
#define ADGSQAA   2
#define ADGSOBPG  3

/* bbp function types */
#define BBPTAB     0
#define BBPS       1
#define BBPSHAL    2
#define BBPSQAA    3
#define BBPSPML    4
#define BBPSCIOTTI 5
#define BBPSMM01   6
#define BBPSLAS    7
#define BBPLAS     8
#define BBPLASFIX  9
#define BBPQAAFIX 10

/* aph function types */
#define APHTAB     0
#define APHGAUSS   1
#define APHBRICAUD 2
#define APHCIOTTI  3

/* rrs function types */
#define RRSGRD    0
#define RRSFOQ    1


typedef struct giop_ctl_str {

  int npar;            /* # optimized params   */
  int maxiter;         /* max iterations       */

  int fit_opt;         /* optimization routine */
  int aph_opt;         /* aph function type    */
  int adg_opt;         /* adg function type    */
  int bbp_opt;         /* bbp function type    */
  int rrs_opt;         /* rrs function type    */
  int ts_opt;          /* temperature & salinity */
  int wt_opt;          /* do we have input wts */

  int   nwave;         /* # fit wavelengths    */
  float wave [NBANDS]; /* fit wavelengths      */
  int   bindx[NBANDS]; /* index to sensor wave */
  float aw   [NBANDS]; /* aw per fit wave      */
  float bbw  [NBANDS]; /* bbw per fit wave     */
  float wts  [NBANDS]; /* input Rrs wts        */

  float grd[2];        /* RRSGRD param         */
  float foq[NBANDS];   /* RRSFOQ variable      */
  float aph_s;         /* APHS spectral param  */
  float adg_s;         /* ADGS spectral param  */
  float bbp_s;         /* BBPS spectral param  */
  float aph_w;         /* APHS referance wave  */
  float adg_w;         /* ADGS reference wave  */
  float bbp_w;         /* BBPS reference wave  */

  float chl;           /* Input chlorophyll    */

  char    aph_tab_file[FILENAME_MAX];
  int     aph_tab_nw;   /* elements in aph tab */
  float  *aph_tab_w;    /* aph tab wavelengths */
  float **aph_tab_s;    /* aph tab values      */
  int     aph_nvec;     /* number of eigenvect */

  char    adg_tab_file[FILENAME_MAX];
  int     adg_tab_nw;   /* elements in adg tab */
  float  *adg_tab_w;    /* adg tab wavelengths */
  float **adg_tab_s;    /* adg tab values      */
  int     adg_nvec;     /* number of eigenvect */

  char    bbp_tab_file[FILENAME_MAX];
  int     bbp_tab_nw;   /* elements in bbp tab */
  float  *bbp_tab_w;    /* bbp tab wavelengths */
  float **bbp_tab_s;    /* bbp tab values      */
  int     bbp_nvec;     /* number of eigenvect */

  double par[GIOPMAXPAR];  /* starting params      */
  double len[GIOPMAXPAR];  /* characteristic length*/

} giopstr;

void set_giop_aph_s(giopstr *g, float aph_s);
void set_giop_adg_s(giopstr *g, float adg_s);
void set_giop_bbp_s(giopstr *g, float bbp_s);
void set_giop_aph_t(giopstr *g, float aphw[], float aphs[], int aphn);

#endif
